package com.cosmoplat.xikai.business.enums;

import lombok.Getter;

/**
 * @ClassName MaterialEnums
 * @Description 物料枚举
 * @Author wdf
 * @Date 2025/1/23
 */
@Getter
public enum MaterialEnum {
    /**
     * 8KA.183.103	1	轴封法兰
     * BG893.1P-47	1	BG893.1P-47-挡圈GB893.1磷化47
     * 8KA.370.734	1	油封垫圈
     * Z61906	2	GB276深沟球轴承61906
     * 5KA.206.138	1	绝缘轴
     * 8KA.370.733	1	轴封垫圈
     * RM-100051	3.0000	GB13871唇形密封圈B型30x42x7
     * 5KA.743.10036	1	绝缘拉杆
     * RM-100065	3	骨架油封30x42x7
     **/
    M_8KA_183_103("123800183000022", "8KA.183.103", 1, "轴封法兰"),
    M_BG893_1P_47("240001006000119", "BG893.1P-47", 1, "BG893.1P-47-挡圈GB893.1磷化47"),
    M_8KA_370_734("123800370000168", "8KA.370.734", 1, "油封垫圈"),
    M_Z61906("240002002000123", "Z61906", 2, "GB276深沟球轴承61906"),
    M_5KA_206_138("123500206000073", "5KA.206.138", 1, "绝缘轴"),
    M_8KA_370_733("123800370000167", "8KA.370.733", 1, "轴封垫圈"),
    M_RM_100051("231001027000776", "RM-100051", 3, "骨架油封30x42x7"),  // 与RM-100065库存下发的点位相同，使用的同一个工具
    M_5KA_743_10036("123500743000007", "5KA.743.10036", 1, "绝缘拉杆"),
    M_RM_100065("123000220000218", "RM-100065", 3, "骨架油封30x42x7");


    // MDM主数据编码
    private String code;

    // 物料外部编码 - 图号
    private String materialCode;

    // 物料数量
    private Integer num;

    // 物料名称
    private String name;

    MaterialEnum(String code, String materialCode, Integer num, String name) {
        this.name = name;
        this.materialCode = materialCode;
        this.num = num;
        this.code = code;
    }

    public static MaterialEnum getMaterialEnumByCode(String code) {
        for (MaterialEnum materialEnum : MaterialEnum.values()) {
            if (materialEnum.getCode().equals(code)) {
                return materialEnum;
            }
        }
        return null;
    }

    /**
     * 物料为产线系统控制库存的物料
     *
     * @param code
     * @return boolean
     * @date 9:05 2025/1/24
     **/
    public static boolean inStockMaterial(String code) {
        // 轴封法兰

        if (M_8KA_183_103.getCode().equals(code)) {
            return true;
        } else if (M_5KA_206_138.getCode().equals(code)) {
            // 绝缘轴
            return true;
        }
        return false;
    }
}
